package Servlet;

import entity.Pet;
import service.impl.petServiceImpl;

import javax.servlet.annotation.WebServlet;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/select")
public class cha extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        petServiceImpl ps=new petServiceImpl();

        String lei=request.getParameter("lei");
        List<Pet> list=new ArrayList<>();
        list=ps.SelectPetinBreed(lei);

        if (null!=list){
           request.getSession().setAttribute("select",list);
            response.sendRedirect("index.jsp");
        }else{
            response.sendRedirect("index.jsp");
        }
    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {
        doPost(request,response);
    }
}
